package com.alex.springboot.controller;

import com.alex.springboot.dao.CustomerRepository;
import com.alex.springboot.entity.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/customer")
public class CustomerController {

    @Autowired
    private CustomerRepository customerRepository;

    @PostMapping("/save")
    public Customer save(Customer customer) {
        customerRepository.save(customer);
        return customer;
    }

    @GetMapping("/{id}")
    public Customer getById(@PathVariable String id) {
        return customerRepository.findById(id).get();
    }

}
